<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>业务经理评审页面</title>
    <!--1.引入 bootstrap 框架全局样式 -->
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"/>
    <!--2.引入 angularJS 分页的样式 -->
    <link rel="stylesheet" href="../angularjs/pagination.css">
    <!--3.引入 jquery 框架类库 -->
    <script src="../bootstrap/js/jquery.min.js"></script>
    <!--4.引入 bootstrap 框架类库 -->
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <!--5.引入 angularJS 框架类库 -->
    <script src="../angularjs/angular.min.js"></script>
    <!--6.引入 angularJS 框架分页的类库 -->
    <script src="../angularjs/pagination.js"></script>
    <!--7.引入layer css-->
    <link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
    <!--8.引入layer js-->
    <script src="https://www.layuicdn.com/layui/layui.js"></script>
    <style>

        img {
            width: 230px;
            height: 180px;
        }
    </style>
    <script>
        var app = angular.module("FroAloanApp", ['ngCookies']).config(function ($httpProvider) {
            $httpProvider.defaults.useXDomain = true;
            delete $httpProvider.defaults.headers
                .common['X-Requested-With']
        });
        app.controller("FroAloanController", function ($scope, $http, $window, $cookieStore, $element) {
            //首先拿到token跟rname
            var token = $window.localStorage.getItem("tokens");
            $scope.rname = $window.localStorage.getItem("rname");
           //定义传到后台的参数
            $scope.staffExmination={};
            $scope.task={};

            //通过borrower_info_id查询审查专员审查记录
            $scope.getReviewByTid=function(){
                var tsid = $window.localStorage.getItem("tsid");
                var borrowerInfoId=$window.localStorage.getItem("borrowerInfoId");
                console.log(borrowerInfoId);
                $scope.task.token = token;
                $scope.task.tsid=tsid;
                $scope.task.borrowerInfoId=borrowerInfoId;

                $http.post("http://localhost:10088/manager/getReviewByTid?borrowerInfoId="+borrowerInfoId,
                    $scope.task, {headers: {'auth': token}}).success(function (data) {
                    if (data.code==200){
                        $scope.reviewList=data.data;
                        $scope.staffExmination.examinationNum=data.data.length+1;     //根据审批记录写入第几次审批
                    }
                })
            }

            //业务经理提交评审
            $scope.review = function (status) {
                //staffExmination绑定的参数有借款人信息表id，审批意见，状态(审批结果),第几次审批
                var borrowerInfoId = $window.localStorage.getItem("borrowerInfoId");
                $scope.staffExmination.borrowerInfoId = borrowerInfoId;//借款人信息表id
                var tsid = $window.localStorage.getItem("tsid");
                $scope.staffExmination.id = tsid;//tsid为工作人员审核表t_staff_exmination中的id
                $scope.staffExmination.status = status;     //状态(审批结果)

                //添加审查记录
                $http.post("http://localhost:10088/manager/insertReviewRecord"
                    ,$scope.staffExmination, {headers: {'auth': token}}).success(function (data) {

                    if (data.code == 200) {
                        // layer.msg("审批通过");
                        // $window.location.href = "";//
                        layer.msg("审批完成！");
                        location.href="index.html"
                    }else {
                        // layer.msg("审批不通过");
                        // $window.location.href = "";//

                    }
                });
            }

            //页面跳转
            $scope.toPage = function (url) {
                $window.location.href = url;
            };
            //退出登录
            $scope.logout = function () {
                $window.localStorage.setItem("tokens","");
                $window.location.href = "../admin/login.html";
            };
        });
    </script>
</head>
<body ng-app="FroAloanApp" ng-controller="FroAloanController" ng-init="getReviewByTid()">
<div class="navbar navbar-default" >
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">工作人员后台</a>
        </div>
        <ul class="nav navbar-nav">
            <li ><a href="javascript:void(0)" ng-click="toPage('index.html')">任务领取</a></li>
            <li  class="dropdown active">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    我的任务<b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="javascript:void(0)" ng-click="toPage('myCompletingTaskManager.html')">待完成任务</a></li>
                    <li><a href="javascript:void(0)"ng-click="toPage('myCompleteTask.html')">已完成任务</a></li>
                </ul>
            </li>
        </ul>
        <ul class="nav navbar-nav navbar-right">
            <li><a href="#"><span class="glyphicon glyphicon-user"></span>角色: {{rname}}</a></li>
            <li><a href="javascript:void(0)" ng-click="logout()"><span class="glyphicon glyphicon-log-in"></span>注销</a></li>
        </ul>

    </div>

</div>
<div class="container-fluid">
    <div class="panel panel-default">
        <div class="panel-heading" style="text-align: center">
            <h2>评审页面</h2>
        </div>

        <div class="panel-body">
            <form role="form" name="angularForm">
                <div class="modal-body " id="model-body">
                    <table class="table table-striped table-hover table-bordered table-condensed">
                        <tr>
                            <td>工作人员id</td>
                            <td>材料真实性评分</td>
                            <td>申请者评价评分</td>
                            <td>总评</td>
                            <td>审批意见</td>
                            <td>第几次审核</td>
                        </tr>
                        <tr ng-repeat="review in reviewList">
                            <td>{{review.staffMemberId}}</td>
                            <td>{{review.materialAuthenticityScore}}</td>
                            <td>{{review.applicantEvaluation}}</td>
                            <td>{{review.generalComments}}</td>
                            <td>{{review.approvalComments}}</td>
                            <td>
                                <span ng-if="review.examinationNum==1">
                                    第一次审核
                                </span>
                                <span ng-if="review.examinationNum==3">
                                    第二次审核
                                </span>
                                <span ng-if="review.examinationNum==5">
                                    第三次审核
                                </span>
                            </td>
                        </tr>
                    </table>

                    <div class="form-group">
                        <label>评审意见</label>
                        <input ng-model="staffExmination.approvalComments" type="text" class="form-control">
                    </div>

                </div>
                <div class="modal-footer">
                    <div class="form-group">
                        <div class="row">
                            <div class="col-lg-6">
                                <button type="button" class="btn btn-primary form-control" value="通过" ng-click="review(1)">通过
                                </button>
                            </div>
                            <div class="col-lg-6">
                                <button type="button" class="btn btn-primary form-control" value="不通过" ng-click="review(0)">不通过
                                </button>
                            </div>
                        </div>

                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>